<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="zh-CN">
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>TOP标签</title>
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>

<style type="text/css">
#loading{
	width: 120px; height: 20px;
	background: red;
	display:none;
}
</style>

</head>
<body>

<div id="loading">刷新中。。。</div>

<table id="top">

<tbody><tr><th> </th><th>每个K宝的价格(K币)</th><th>挂单数量(K宝)</th></tr>
</tbody>

<tbody id="top-sell"><tr><td>卖5</td><td>51000</td><td>8</td></tr><tr><td>卖4</td><td>53000</td><td>15</td></tr><tr><td>卖3</td><td>54000</td><td>20</td></tr><tr><td>卖2</td><td>55000</td><td>30</td></tr><tr><td>卖1</td><td>56000</td><td>10</td></tr></tbody>

<tbody id="top-buy"><tr><td>买1</td><td>50000</td><td>5</td></tr><tr><td>买2</td><td>49900</td><td>10</td></tr><tr><td>买3</td><td>49000</td><td>18</td></tr><tr><td>买4</td><td>48000</td><td>25</td></tr><tr><td>买5</td><td>47000</td><td>28</td></tr></tbody>

</table>


<script type="text/javascript">


$(document).ready(function(){

getTop();
var iTime = setInterval(getTop, 5000);

	// 试用JSON传输数据，修正IE6下jQuery解析XML的错误
	function getTop(){
		$.post("bg-top-json-procedure.php",{
				action: 'getTop'
				}, function(data,textStatus){ 
					addMsg(data); 
				}, "json");
	} //END func getTop
	
	function addMsg(data){
		$("#top-sell").empty();
		$.each(data['sell'], function(i,n){
			var msg = '<tr><td>卖'+(i+1)+'</td><td>'+n['price']+'</td><td>'+n['num']+'</td></tr>';
			$("#top-sell").prepend( msg );
		});

		var j = 5;
		$("#top-buy").empty();
		$.each(data['buy'], function(i,n){
			var msg = '<tr><td>买'+j+'</td><td>'+n['price']+'</td><td>'+n['num']+'</td></tr>';
			$("#top-buy").prepend( msg );
			j--;
		});
		
	} //END func addMsg

	 $("#loading").ajaxStart(function(){
		   $(this).show();
		 }); 
	 $("#loading").ajaxStop(function(){
		   $(this).hide();
		 }); 
	 
});
</script>


</body>
</html>